Q: Reversing a word using stack can be used to find if the given word is a palindrome or not.
Solution: This application of stack can also be used to find if the given word is a palindrome because, if the reversed is same as that of the original word, the given word is a palindrome.
Q: Which is the most appropriate data structure for reversing a word?
Solution: Stack is the most appropriate data structure for reversing a word because stack follows LIFO principle.
Q: Operations required for reversing a word or a string using stack are push() and pop().
Solution: Push operation inserts a character into the stack and pop operation pops the top of the stack.
Q: What is the time complexity of reversing a word using stack algorithm?
Solution: The time complexity of reversing a stack is mathematically found to be O (N) where N is the input.
Q: What will be the word obtained if the word “abbcabb” is reversed using a stack?
Solution: The string “abbcabb” is pushed on to the stack. If the characters are popped one by one, the word obtained will be bbacbba.
Q: How many stacks are required for reversing a word algorithm?
Solution: Only 1 stack is required for reversing a word using stack. In that stack, push and pop operations are carried out.
Q: What will be output if the following sequence of operations are executed? Push(a,s); Push(b,s); Pop(b); Push(c,s);
Solution: The element ‘b’ is popped out of the stack. Hence the output of the following sequence of operations will be ‘b’.
Q: What are the set of functions that are to be executed to get the following output? cat
Solution: During push operation, the characters ‘c’, ’a’, ’t’ are inserted into the stack and popped immediately after push.
You Have Score    | /8 |